package test.Memcached;
import java.io.IOException;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.Date;

public class MemcacheUse {

	private static class MyData implements Serializable {
		private static final long serialVersionUID = 1L;
		private long d = new Date().getTime();

		public String toString() {
			return "my data [" + d + "]";
		}
	}

	public static void main(String[] args) throws IOException {
		MyData myData = new MyData();

		MemcachedClient c = new MemcachedClient(new InetSocketAddress("localhost", 11211));
		// Store a value (async) for one hour

		c.set("someKey", 3600, myData);
		// c.set("someKey", 3600, "yada11");

		// Retrieve a value (synchronously).
		Object myObject = c.get("someKey");

		c.shutdown();

		System.out.println(myObject);

	}

}